using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

using Deepcode.Flux.Core.Data;
using Deepcode.Flux.Core.Systems.Workflow.Enums;

namespace Deepcode.Flux.Core.Systems.Workflow.Bases
{
	/// <summary>
	/// Represents a workflow processstart within WFProcessStart
	/// </summary>
	public class ProcessStart
	{
		// Private fields for storing record fields //
		private int				_PK_ID = -1;
		private int				_FK_ProcessID = -1;
		private int				_Rank = -1;
		private string			_Method = "";
		private string			_PropertyBag = "";

		// Public fields exposing record fields //
		public int PK_ID { get { return _PK_ID; } set { _PK_ID = value; } }
		public int FK_ProcessID { get { return _FK_ProcessID; } set { _FK_ProcessID = value; } }
		public int Rank { get { return _Rank; } set { _Rank = value; } }
		public string Method{ get{ return _Method; } set{ _Method = value; }}
		public string PropertyBag{ get{ return _PropertyBag; } set{ _PropertyBag = value; }}
		
		// Linkbacks
		public Process ParentProcess
		{
			get
			{
				Processes ps = new Processes();
				return ps.GetProcessByID( this.FK_ProcessID );
			}
		}

		// Constructor to create new without loading
		public ProcessStart() { }

		// Constructor loading from a data row
		public ProcessStart(DataRow InitFromRow)
		{
			_PK_ID = SQLUtility.DBNull(InitFromRow["PK_ID"], -1);
			_FK_ProcessID = SQLUtility.DBNull(InitFromRow["FK_ProcessID"], -1);
			_Rank = SQLUtility.DBNull(InitFromRow["Rank"], -1);
			_Method = SQLUtility.DBNull(InitFromRow["Method"], "");
			_PropertyBag = SQLUtility.DBNull(InitFromRow["PropertyBag"], "");
		}
	}
}
